package org.i0o.webplus.web.uicomponent.ext;

import java.util.ArrayList;
import java.util.List;

/**
 * Ext Tree 数据容器
 * 
 * @author <a href="mailto:781131@gmail.com">HTF</a>
 * @version 2010-6-11
 */
public class TreeData {
	public TreeData() {

	}

	public TreeData(String text) {
		this.text = text;
	}

	public TreeData(int id, String text) {
		this.id = id;
		this.text = text;
	}

	public TreeData(String text, boolean leaf) {
		this.text = text;
		this.leaf = leaf;
	}

	private int id;

	private String text;

	private boolean leaf;

	private String qtip;

	private String cls;

	private List<TreeData> children = new ArrayList<TreeData>();

	/**
	 * Get node ID
	 * 
	 * @return 节点ID
	 */
	public int getId() {
		return id;
	}

	/**
	 * Set node ID
	 * 
	 * @param id
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * 获取节点文本
	 * 
	 * @return 节点文本
	 */
	public String getText() {
		return text;
	}

	/**
	 * 设置节点文本
	 * 
	 * @param text
	 */
	public void setText(String text) {
		this.text = text;
	}

	/**
	 * 判断是否为末级菜单
	 * 
	 * @return 判断结果
	 */
	public boolean isLeft() {
		return leaf;
	}

	/**
	 * 设置是否是末级菜单
	 * 
	 * @param left
	 */
	public void setLeft(boolean leaf) {
		this.leaf = leaf;
	}

	/**
	 * 获取节点图标
	 * 
	 * @return 节点图标路径
	 */
	public String getCls() {
		return cls;
	}

	/**
	 * 设置节点图标
	 * 
	 * @param cls
	 */
	public void setCls(String cls) {
		this.cls = cls;
	}

	/**
	 * 获取子菜单
	 * 
	 * @return 子菜单列表
	 */
	public List<TreeData> getChildren() {
		return children;
	}

	/**
	 * 设置子菜单，如果left为true的时候无效
	 * 
	 * @param children
	 */
	public void setChildren(List<TreeData> children) {
		this.children = children;
	}

	/**
	 * 添加子菜单
	 * 
	 * @param children
	 */
	public void addChildren(TreeData children) {
		this.children.add(children);
	}

	/**
	 * 获取节点的提示信息
	 * 
	 * @return
	 */
	public String getQtip() {
		return qtip;
	}

	/**
	 * 设置节点的提示信息
	 * 
	 * @param qtip
	 */
	public void setQtip(String qtip) {
		this.qtip = qtip;
	}
	
	public void addChildItem(TreeData treeData) {
		this.children.add(treeData);
	}

}
